package com.demo.web;

import com.demo.dto.BaseResult;
import com.demo.dto.ListResult;
import com.demo.dto.Pagination;
import com.demo.entity.SalePersonAccount;
import com.demo.service.ISalePersonAccountService;
import com.demo.vo.SalePersonAccountVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/admin/salePersonAccount")
public class SalePersonAccountController {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private ISalePersonAccountService service;

    /***
     * 分页查询
     * @param arg
     * @return
     */
    @ResponseBody
    @RequestMapping(value = "/query", method = RequestMethod.GET)
    public ListResult<SalePersonAccountVo> query(SalePersonAccountVo arg) {
        List<SalePersonAccountVo> list = service.queryByPage(arg);
        int total = service.queryCountByPage(arg);
        Pagination page = new Pagination(arg.getPage(), total, arg.getSize());
        ListResult<SalePersonAccountVo> res = new ListResult(true, list);
        res.setPage(page);
        return res;
    }
    @ResponseBody
    @RequestMapping(value = "/get", method = RequestMethod.GET)
    public BaseResult<SalePersonAccount> get(SalePersonAccountVo arg) {
        SalePersonAccount data = service.selectBySaleId(arg.getSaleId());
        BaseResult<SalePersonAccount> res = new BaseResult(true, data);
        return res;
    }

}
